<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="./plugins/vue/dist/vue.min.js"></script>
    <script type="text/javascript" src="./plugins/axios/dist/axios.min.js"></script>
    <script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
<div id="app"></div>
</body>
<script type="text/javascript">
    new Vue({
        el: "#app",
        mounted(){
            //要获取授权码
            let param = getParam();
            //处理回调方法
            this.$http.post("/wechat/handleCallBackMethod", param).then(res => {
                let {success, msg, resultObject} = res.data;
                //如果success为true，并且也响应了openid，就跳转到绑定界面
                if(success&&resultObject.openid){
                    location.href = "/binder.html?openid="+resultObject.openid;
                }else if(success&&resultObject.token&&resultObject.loginUser){
                    localStorage.setItem("token",resultObject.token);
                    localStorage.setItem("loginUser", JSON.stringify(resultObject.loginUser));
                    location.href = "/index.html";
                }else{
                    alert(msg);
                }
            });

        }
    });
</script>
</html>